import 'package:base_flutter/base_flutter.dart';
import 'package:ls_work/net/api/http_api.dart';
import 'package:ls_work/net/post_request.dart';

class LeaveModel extends BaseMvvmModel{
  @override
  void onCleared() {
  }


  Future<String> calculateLeaveDays(String leaveDate,String backDate) async {
    var map = {
      "leaveDate":leaveDate,
      "backDate":backDate,
    };

    var data = await HttpGo.instance.postData(HttpApi.calculateLeaveDays,data: map,options: PostRequest.urlencodedHeader);
    if('0'==data['code'].toString()){
      return data['data'].toString();
    }else{
      throw data['msg'];
    }
  }

  Future<Map> confirmLeave(
      {String? id, String? backTime, String? backRemark, String? leaveDay}) async {
    var map = {
      "isAppInitiateRefund":0,
      "id":id,
      "backTime":backTime,
      "backRemark":backRemark,
      "leaveDay":leaveDay
    };

    var data = await HttpGo.instance.postData(HttpApi.confirmLeave,data: map.toJsonMapStr(),options: PostRequest.urlencodedHeader);
    if("0"==data['code'].toString()){
      return data;
    }else{
      throw data['msg'];
    }
  }
}